﻿using System;
using Omnia.Infrastructure;
using System.Data.Linq.Mapping;

namespace Omnia.DataModels
{
    [Table(Name = "Budgets")]
    public class BudgetInfo : NotificationObject
    {
        #region Fields
        private string guid = System.Guid.NewGuid().ToString();
        private int year = DateTime.Now.Year;
        private int month = DateTime.Now.Month;
        private double value = 0;
        private double outlay = 0;
        #endregion

        #region Properties
        [Column(IsPrimaryKey = true)]
        public string Guid
        {
            get { return guid; }
            set
            {
                guid = value;
                RaisePropertyChanged(() => Guid);
            }
        }

        [Column]
        public int Year
        {
            get { return year; }
            set
            {
                year = value;
                RaisePropertyChanged(() => Year);
            }
        }

        [Column]
        public int Month
        {
            get { return month; }
            set
            {
                month = value;
                RaisePropertyChanged(() => Month);
            }
        }

        [Column]
        public double Value
        {
            get { return value; }
            set
            {
                this.value = value;
                RaisePropertyChanged(() => Value);
                RaisePropertyChanged(() => Balance);
            }
        }

        public double Outlay
        {
            get { return outlay; }
            set
            {
                outlay = value;
                RaisePropertyChanged(() => Outlay);
                RaisePropertyChanged(() => Balance);
            }
        }

        public double Balance
        {
            get
            {
                return Value - Outlay;
            }
        }

        public DateTime Date
        {
            get
            {
                return new DateTime(Year, Month, 1);
            }
        }
        #endregion
    }
}
